package com.yidu.t299.dao.cfj;

import com.yidu.t299.domain.cfj.Job;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface JobMapper {
    /**
     * 根据编号删除信息
     * @param jobId 编号
     * @return 影响的行数(返回1则为成功)
     */
    @Delete({
        "delete from job_setting" +
        " where job_id = #{job_id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer jobId);

    /**
     * 添加信息
     * @param job
     * @return 影响的行数(返回1则为成功)
     */
    @Insert({
        "insert into job_setting (job_id, job_name)" +
        " values (#{jobId,jdbcType=INTEGER}, #{jobName,jdbcType=VARCHAR})"
    })
    int insert(Job job);

    /**
     * 根据编号查询指定的信息
     * @param jobId
     * @return
     */
    @Select({
        "select" +
        " job_id, job_name" +
        " from job_setting" +
        " where job_id = #{jobId,jdbcType=INTEGER}"
    })
    @Results(id = "JobMap",value = {
            @Result(id = true,column = "job_id",property = "jobId"),
            @Result(column = "job_name",property = "jobName")
    })
    Job selectByPrimaryKey(Integer jobId);

    /**
     * 按条件分页查询校区数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @param condition 条件参数
     * @return 校区对象集合
     */
    @Select("select * from job_setting where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("JobMap")
    List<Job> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 按条件查询表中数据行数
     * @param condition 条件参数
     * @return 数据行数
     */
    @Select("select count(*) from job_setting where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

    /**
     * 根据信息修改其数据
     * @param job
     * @return 影响的行数(返回1则为成功)
     */
    @Update({
        "update job_setting",
        " set job_name = #{jobName,jdbcType=VARCHAR}",
        " where job_id = #{jobId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Job job);
}